package com.test.vo;

import java.util.List;

public class PageView {

	private int totalPage;
	private int totalRecord;
	private int curentPage;
	private int pageCount = 10;
	private int startPage;
	private int endPage;
	private List list;
	private int pageWidth = 10;

	public int getStartPage() {

		int maxPage = this.getCurentPage() + 5;
		if (this.getTotalPage() <= 10) {
			// 如果小于10页
			this.setStartPage(1);
			this.setEndPage(this.getTotalPage());
			return 1;
		}
		// 1 ,2,3,4,5,6,7,8,9,10,11
		else if (maxPage > this.totalPage && this.getTotalPage() > 10) {
			// 如果大于10页
			this.setStartPage(this.getTotalPage() - 9);
			this.setEndPage(this.getTotalPage());
			return this.getTotalPage() - 9;
		} else if (maxPage <= this.totalPage && this.getTotalPage() > 10) {

			if (this.getCurentPage() - 4 >= 0) {
				this.setStartPage(this.getCurentPage() - 4);
				this.setEndPage(maxPage);
				return this.getCurentPage() - 4;
			} else if (this.getCurentPage() - 4 < 0) {
				this.setStartPage(1);
				this.setEndPage(10);
				return 1;
			}
		}else if(this.curentPage<0){
			this.curentPage=1;
			this.setStartPage(1);
			return 1;
		}
		return 1;
	}

	public void setStartPage(int startPage) {
		/**
		 * 总共显示10页
		 */

		this.startPage = startPage;
	}

	public int getEndPage() {
		
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}

	public int getTotalPage() {

		if (this.getTotalRecord() % this.pageCount == 0) {
			this.totalPage = this.getTotalRecord() / this.pageCount;
		} else {
			this.totalPage = this.getTotalRecord() / this.pageCount + 1;
		}
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRecord() {
		return totalRecord;
	}

	public void setTotalRecord(int totalRecord) {
		this.totalRecord = totalRecord;
	}

	public int getCurentPage() {
		if(this.curentPage>=this.getTotalPage()){
			this.setCurentPage(this.totalPage);
		}
		return curentPage;
	}

	public void setCurentPage(int curentPage) {
		this.curentPage = curentPage;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	
}
